<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/template/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/template/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__STATIC__/template/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->


    <title>产品列表</title>
    <link href="__STATIC__/template/lib/lightbox2/2.8.1/css/lightbox.css" rel="stylesheet" type="text/css" >
</head>
<body class="pos-r">
<style>
    #DataTables_Table_0_info {
        display: none;
    }
    #DataTables_Table_0_paginate{
        display: none;
    }
    td{
        text-align:center; /*设置水平居中*/
        vertical-align:middle;/*设置垂直居中*/
    }
    /*分页样式*/
    .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}
    .pagination li{margin:0px 10px; border:1px solid #e6e6e6;padding: 3px 8px;display: inline-block;}
    .pagination .active{background-color: #46A3FF;color: #fff;}
    .pagination .disabled{color:#aaa;}
    a:hover{color: #ff081f; /*鼠标在a上面时,变蓝色*/}

</style>
<div>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span> 积分商品管理
        <span class="c-gray en">&gt;</span> 产品列表
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <div class="text-c">
            <input type="text" value="{$title ? $title : ''; }" class="input-text" style="width:250px" placeholder="商品标题" id="title" name="title" >
            <button type="submit" class="btn btn-success" onclick="find()"  name="submit" >
                <i class="icon-search"></i> 搜产品
            </button>

        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20" id="load">
			<span class="l">
				<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
                    <i class="Hui-iconfont" >&#xe6e2;</i> 批量删除
                </a>

				<a class="btn btn-primary radius" href="{:url('goods_add')}">
                    <i class="Hui-iconfont">&#xe600;</i> 添加产品
                </a>
			</span> <span class="r">共有数据：<strong>{$count}</strong> 条</span>
        </div>
        <div class="mt-20" id="replace">
            <table class="table table-border table-bordered table-bg table-hover table-sort" >
                <thead>
                <tr class="text-c">
                    <th width="40">
                        <input name="" type="checkbox" value="0" class="productCheck">
                    </th>
                    <th width="50">ID</th>
                    <th width="60">缩略图</th>
                    <th width="100">商品标题</th>
                    <th width="100">市场价</th>
                    <th width="100">积分数</th>
                    <th width="100">添加时间</th>
                    <th width="60">发布状态</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                {volist name='goods' id='v' empty='$empty'}
                <tbody>
                <tr class="text-c va-m">
                    <td style="vertical-align:middle">
                        <input name="" type="checkbox" value="{$v.id}" class="productCheck">
                    </td>
                    <td width="40" style="vertical-align:middle">{$v.id}</td>
                    <td style="vertical-align:middle">
                        {empty name='$v.image'}
                        <span>暂无图片</span>
                        {else /}
                            {foreach $v.img as $c}
                                {if condition='$v.img[0] eq $c'}
                                <a href="_GOODS_/{$v.img[0]}" onclick="img_show(this)" title="点击查看全部图片" data-lightbox="gallery.{$v.id}">
                                    <img width="60" class="picture-thumb" src="_GOODS_/{$v.img[0]}">
                                </a>
                                {else /}
                                <a href="_GOODS_/{$c}" data-lightbox="gallery.{$v.id}" style="display: none">
                                    <img width="60" class="picture-thumb" src="_GOODS_/{$c}">
                                </a>
                                {/if}
                            {/foreach}
                        {/empty}

                    </td>
                    <td class="text-1" style="vertical-align:middle">{$v.title}</td>
                    <td class="text-1" style="vertical-align:middle">{$v.s_price}元</td>
                    <td class="text-1" style="vertical-align:middle">{$v.integral}</td>
                    <td class="text-1" style="vertical-align:middle">{$v.time|date='Y-m-d',###}</td>
                    <td class="td-status" style="vertical-align:middle">
                        {if condition="$v.is_down eq 1"}
                        <span class="label label-success radius">已发布</span>
                        {else \}
                        <span class="label label-defaunt radius">已下架</span>
                        {/if}
                    </td>
                    <td class="td-manage " style="vertical-align:middle">
                        {if condition="$v.is_down eq 1"}
                        <a style="text-decoration:none" onClick="product_stop(this,'{$v.id}')" href="javascript:;" title="下架" >
                            <i class="Hui-iconfont">&#xe6de;</i>
                        </a>
                        {else \}
                        <a style="text-decoration:none" onClick="product_start(this,'{$v.id}')" href="javascript:;" title="发布">
                            <i class="Hui-iconfont">&#xe603;</i>
                        </a>
                        {/if}
                        <a style="text-decoration:none" class="ml-5"  href="{:url('goods_add')}?id={$v.id}" title="编辑">
                            <i class="Hui-iconfont">&#xe6df;</i>
                        </a>
                        <a style="text-decoration:none" class="ml-5" onClick="product_del(this,'{$v.id}')" href="javascript:;" title="删除">
                            <i class="Hui-iconfont">&#xe6e2;</i>
                        </a>
                    </td>
                </tr>
                </tbody>
                {/volist}
            </table>
            <div class="col-md-8 col-xs-6">{$goods->render()}</div>
        </div>

    </div>

</div>



<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/template/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/template/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/lightbox2/2.8.1/js/lightbox.min.js"></script>
<script type="text/javascript">

    function img_show(obj){
        $(obj).Huihover();
    }

    /*产品-搜索*/
    function find(){
        //alert(1);
        var title = $.trim($('#title').val());
        var url = "{:url('product_search')}";

        var data = {
            title:title
        }
        $.post(url,data,function(result){
            // console.log(result);
            if(result.ok==false){
                layer.msg(result.msg,{icon:1,time:2000});
            }else{
                $("body").empty();
                $("body").append(result);
            }
        })

    }



    /*产品-下架*/
    function product_stop(obj,id){

        layer.confirm('确认要下架吗？',function(index){
            var url = "{:url('down')}";
            $.post(url,{id:id},function(result){
                //  console.log(result);
                if(result.ok){
                    layer.msg(result.msg,{icon:1,time:2000});
                    setTimeout("window.location.replace(location.href)",1000);
                }else{
                    layer.msg(result.msg,{icon:0,time:2000});
                }
            })

        });
    }

    /*产品-发布*/
    function product_start(obj,id){
        layer.confirm('确认要发布吗？',function(){
            var url = "{:url('up')}";
            $.post(url,{id:id},function(result){
                if(result.ok){
                    layer.msg(result.msg,{icon:1,time:2000});
                    setTimeout("window.location.replace(location.href)",1000);
                }else{
                    layer.msg(result.msg,{icon:1,time:2000});
                }
            })
        });
    }


    /*产品-删除*/
    function product_del(obj,id){
        layer.confirm('删除后将不可恢复，确定删除吗？',function(index){

            var url ="{:url('product_del')}";
            $.post(url,{id:id},function(result){
                console.log(result);
                if(result.ok){
                    $(obj).parents("tr").remove();
                    layer.msg(result.msg,{icon:1,time:2000});
                }else{
                    layer.msg(result.msg,{icon:1,time:2000});
                }
            })

        });
    }
    /*产品-批量删除*/
    function datadel(){
        //alert(1);
        var obj = document.getElementsByClassName('productCheck');
        var num = $('input[type=checkbox]:checked').length;
        if(num==0){
            layer.msg('未选取删除对象！',{icon:0,time:2000});
        }else{
            layer.confirm('批量删除须谨慎，是否删除？',function(){
                var ids = new Array();
                $.each($('input:checkbox:checked'),function(){
                    if(parseInt($(this).val())>0){
                        ids.push(parseInt($(this).val())) ;
                    }

                });
                var data = { ids:ids };
                $.post("{:url('productDatadel')}",data,function(result){
                    console.log(result);
                    if(result.ok){
                        $(obj).parents("tr").remove();
                        layer.msg(result.msg,{icon:1,time:2000});
                    }else{
                        layer.msg(result.msg,{icon:1,time:2000});
                    }
                });
            });
        }
    }
</script>
</body>
</html>